package com.itheima.reggie.common;

import lombok.Data;

/**
 * 通用返回结果，服务端响应的数据最终都会封装成此对象
 * @param <Object>
 */
@Data
public class R<Object> {//响应数据 code msg data
    private Integer code;//code = 0 || code != 1 失败  code = 1 成功
    private String msg;//错误信息
    private Object data;//数据

    //成功
   /* public static <T> R<T> success(T object){
        return
    }*/
    public static <Object> R<Object> success(Object object){
        R<Object> r = new R<>();
        r.code = 1;
        r.data = object;
        return r;
    }
    //失败
    public static <Object> R<Object> error(String msg){
        R<Object> r = new R<>();
        r.code = 0;
        r.msg = msg;
        return r;
    }
}
